Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The intent of this pull request is to implement what I've termed a "lightweight" Query Factory. The lightweight implementation is optimized for speed, when it comes to constructing the query and generating the corresponding SOQL string. Here is a brief summary of the changes at the core of the lightweight implementation:
The lightweight implementation does sacrifice some functionality in order to achieve a significant reduction in query build time. Here's a summary of what you lose when you use the lightweight implementation:
Using the SelectorPerformance class developed by @daveespo (with slight modification to allow me to easily switch between the lightweight and regular implementations) I came up with the following benchmark numbers for 10 query "build" operations:
With lightweight = false:
11:27:55.52 (1673553331)|USER_DEBUG|[42]|DEBUG|Preload Elapsed:29
11:27:55.52 (1673623737)|USER_DEBUG|[43]|DEBUG|Parent Elapsed:314
11:27:55.52 (1673691877)|USER_DEBUG|[44]|DEBUG|Grandparent Elapsed:436
11:27:55.52 (1673766529)|USER_DEBUG|[45]|DEBUG|QF Elapsed (includes parent & grandparent):813
11:27:55.52 (1673837762)|USER_DEBUG|[46]|DEBUG|SOQL Elapsed:799
11:27:55.52 (1673908107)|USER_DEBUG|[47]|DEBUG|Total Elapsed:1612
With lightweight = true:
11:29:35.14 (416745051)|USER_DEBUG|[42]|DEBUG|Preload Elapsed:15
11:29:35.14 (416811125)|USER_DEBUG|[43]|DEBUG|Parent Elapsed:22
11:29:35.14 (416874242)|USER_DEBUG|[44]|DEBUG|Grandparent Elapsed:22
11:29:35.14 (416942885)|USER_DEBUG|[45]|DEBUG|QF Elapsed (includes parent & grandparent):124
11:29:35.14 (417009114)|USER_DEBUG|[46]|DEBUG|SOQL Elapsed:263
11:29:35.14 (417075267)|USER_DEBUG|[47]|DEBUG|Total Elapsed:387
This represents approximately a 75% reduction in the time required to construct the query factory, set the query fields and generate the SOQL string.